<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" type="text/css" th:href="@{/static/layui/css/layui.css}" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/organization/thesame.css}" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/footer.css}">
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/wardRound/rightCon.css}" media="all" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/page.css}" media="all" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/wardRound/popCss.css}" media="all"/>
		<style type="text/css">
			.add-mess-flex .add-mess-child:nth-child(3n+1) > div:nth-child(1) {
				position: absolute;
				top: 0;
				left: 0;
				width: 135px;
				text-align: right;
			}
			.add-mess-flex .add-mess-child:nth-child(3n+1) > div:nth-child(2) {
				padding-left: 135px;
				margin-right: 40px;
			}
			/* 公开弹窗 */
			.add-mess-form-border p{ border: 1px solid #ddd; border-radius: 4px; padding: 0 10px;  width: 300px; box-sizing: border-box; }
			.add-mess-form-border span{ position: absolute; right: 0; top: 0; width: 50px; height: 33px; text-align: center; border-left: 1px solid #ddd; }
			.add-mess-form-border span img{ width: 20px; }
			.add-mess-pos{ position: absolute; right: 0; top: 10px; }



			.pop-form label{ line-height: 32px; padding: 0; text-align: left; }
			.pop-form .layui-input-block{ margin-left: 80px; }

			.pop-form-width .layui-form-label{ width: 60px; }
			.pop-form-width .layui-input-block{ margin-left: 60px; }
			.layui-input-block-two p{ width: 180px; }

		</style>
	</head>

	<body class="layui-layout-body">
	<div class="layui-body pad12px">
		<!-- 内容主体区域 -->
		<div class="layui-box-con relative">
			<div class="layui-left-con layui-left-label-con pad12px">
				<div class="border-radius4 bgWhite box-shadows">
					<div class="new-add-box-scroll">
						<nav class="label-nav-con" lay-filter="buildingFilter">
							<!-- <p class="f16px lh40px" style="padding-left: 33px;">全部</p> -->
							<input type="hidden" id="buildingNo" value="" name="">
							<ul class="lh40px f14px">
								<li  style="padding-left:33px" value=""  class="current">全部</li>
								<li th:each="list:${buildingList}" th:value="${list.buildingNo}"  th:text="${list.buildingName}"></li>
							</ul>
						</nav>
					</div>
				</div>
			</div>
			<div class="layui-right-con layui-right-label-con" >
				<div class="border-radius4 bgWhite box-shadows">
					<div class="add-box-scroll">
						<div class="layui-tab layui-tab-time">
							<!--<div class="layui-form layui-tab" lay-filter="isStayBackFilter">
								<ul class="layui-tab-title pl25px">
									&lt;!&ndash; 1-否 2-是 &ndash;&gt;
									<li value="1" class="layui-this">现有老人</li>
									<input type="hidden" id="isStayBack" name="">>
								</ul>
							</div>-->
							<div class="layui-tab-content bgWhite pad25px">
								<div class="layui-tab-item layui-show">
									<div class="mb25px more-date border-bot1px">
										<div class="add-mess-flex ">
											<div class="add-mess-child">
												<div>
													<label>楼层：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<select id="floorNo" class="form-select">
															<option value ="">选择</option>
														</select>
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>房间号：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<input autocomplete="off" id="roomName" type="text" placeholder="请输入">
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>床号：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<input autocomplete="off" id="bedName" type="text" placeholder="请输入">
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>姓名：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<input autocomplete="off" id="userName" type="text" placeholder="请输入">
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>护理评估有效时间：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<input id="nextEffectDate" readonly type="text" placeholder="请输入" class="layui-time test-item1">
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>评估有效时间：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<input id="validDate" readonly type="text" placeholder="请输入" class="layui-time test-item2">
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>护理员：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<input id="staffName" onclick="staffInfoLayerOpen()" readonly="readonly"  type="text" placeholder="请输入">
														<input id="staffNo" type="hidden" value="" name="">
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>入驻时间：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<input id="startDate" type="text" placeholder="请输入" class="layui-time test-item3">
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>合同截止时间：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<input id="endDate" type="text" placeholder="请输入" class="layui-time test-item4">
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>性别：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<select id="userSex" class="form-select">
															<option value ="">全部</option>
															<option value="1">男</option>
															<option value="2">女</option>
														</select>
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>护理等级：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<select id="nursingCostNo" name="" class="form-select">
															<option value ="">全部</option>
															<option th:each="list:${pageData.nursingCostList}" th:value="${list.costNo}"  th:text="${list.costName}"></option>
														</select>
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>评估等级：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<select  id="assessmentCostNo" class="form-select">
															<option value ="">全部</option>
															<option th:each="list:${pageData.assessmentCostList}" th:value="${list.costNo}"  th:text="${list.costName}"></option>
														</select>
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>认知：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<select name="" id="cognitionStatus" class="form-select">
															<option value ="">全部</option>
															<option value ="0">否</option>
															<option value ="1">是</option>
														</select>
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>年龄范围：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<select  id="age" class="form-select">
															<option value ="">请选择</option>
															<option value ="1">60岁以下</option>
															<option value ="2">60-69岁</option>
															<option value ="3">70-79岁</option>
															<option value ="4">80-89岁</option>
															<option value ="5">90-99岁</option>
															<option value ="6">100岁及以上</option>
														</select>
													</p>
												</div>
											</div>
											<div class="add-mess-child">
												<div>
													<label>费用排序：</label>
												</div>
												<div class="add-mess-form">
													<p>
														<select name="" id="sort" class="form-select">
															<option value ="1">全部</option>
															<option value ="1">费用从高到低</option>
															<option value ="2">费用从低到高</option>
														</select>
													</p>
												</div>
											</div>
										</div>
										<div class="pt15px pb15px textRight">
											<p class="layui-btn" onclick="query()">查&nbsp;询</p>
											<p class="layui-btn layui-btn-primary" onclick="reset()">重&nbsp;置</p>
											<p class="green cursor right lh32px ml25px btn-select"><span>展开</span><img src="../static/elderlyInfo/img/select_icon_down.png" class="ml10px"></p>
										</div>
									</div>
									<div class="lh32px overflow add-btn-input mb20px">
										<!--<p class="left cursor">
											<span class="white border-radius4 bgGreen inline-block pl15px pr15px" style="display: none;" id="addSpan" onclick="addLayerOpen()">
												<img src="../static/elderlyInfo/img/button_add.png">新建
											</span>
										</p>-->
										<p class="right">
											<span>共有<em class="red fb ml5px mr5px" id="totalNum"></em>人</span>
										</p>
									</div>
									<div class="border1px border-radius4 relative mb40px layui-table-img">
										<table class="layui-hide" id="test" lay-filter="test"></table>
										<!-- <div class="number-page">共有<span class="red">120</span>条数据</div> -->
									</div>
								</div>
								<div class="layui-tab-item">
									<article>454545</article>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div id="nursingStaffInfo" style="display: none;">
		<div class="pop-up">
			<div>
				<div class="pop-title relative overflow mb15px">
					<span class="ml15px">护理员</span>
					<p class="right"><img src="../static/elderlyInfo/img/close_icon.png" class="block pop-close"><p>
				</div>
				<div class="border-top1px mt10px">
					<div class="overflow mt20px mb20px lh32px">
						<p class="left">共有<span id="totalNum2" class="red"></span>条数据</p>
						<div class="add-mess-form-border right relative ml30px">
							<p><input id="searchStaffName" type="text" placeholder="请输入"></p>
							<span onclick="getStaffInfoList()"><img src="../static/elderlyInfo/img/icon_search.png"></span>
						</div>
					</div>
					<article class="pop-box">
						<div class="pop-box-scroll">
							<div class="border1px border-radius4">
								<table class="layui-hide" id="test2" lay-filter="test2"></table>
							</div>
						</div>
					</article>
				</div>
				<div class="btn-con btn-con-position textCenter mt20px">
					<span class="btn-one cursor" onclick="cancelOfLayerOpen()">取&nbsp;消</span>
					<span class="btn-two cursor" onclick="confirmOfLayerOpen()">提&nbsp;交</span>
				</div>
			</div>
		</div>
	</div>

	<script src="../static/elderlyInfo/main/js/jquery-2.1.3.min.js"></script>
	<script src="../static/elderlyInfo/main/layui/layui.js" charset="utf-8"></script>
	<script>

		$(function(){
			layui.use(['element', 'table', 'layer', 'laydate'], function() {
				var laydate = layui.laydate;
				laydate.render({
					elem: '.test-item1',
					trigger: 'click',
				});
				laydate.render({
					elem: '.test-item2',
					trigger: 'click',
				});
				laydate.render({
					elem: '.test-item3',
					trigger: 'click',
				});
				laydate.render({
					elem: '.test-item4',
					trigger: 'click',
				});

			});

			//展开收起
			$('.more-date div.add-mess-child:gt(5)').hide();
			$('.btn-select').click(function() {
				if ($(this).find('img').attr('src') == '../static/elderlyInfo/img/select_icon_down.png') {
					$(this).find('img').attr('src', '../static/elderlyInfo/img/select_icon_up.png').siblings("span").text("收起");
				} else {
					$(this).find('img').attr('src', '../static/elderlyInfo/img/select_icon_down.png').siblings("span").text("展开");
				}
				$('.more-date div.add-mess-child:gt(5)').slideToggle(300);
			})


			//侧边栏选中样式
			$('.label-nav-con li').click(function() {
				$(this).addClass('current').siblings().removeClass('current');
				if (isNull($(this).attr("value"))) {
					$("#addSpan").css("display","none");
				}else{
					$("#addSpan").css("display","");
				}
				$("#buildingNo").val($(this).attr("value"));
				getFloorData();
				query();
			})

			//分页查询
			query();


			//先赋值 是否退住 1-否 2-是
			$("#isStayBack").val("1");
			//选项卡监听
			layui.use('element', function(){
				var element = layui.element;
				element.on('tab(isStayBackFilter)', function(data){
					$("#isStayBack").val(data.elem.context.value);
					query();

				});
			});

		})



		//重置
		function reset(){
			$("#roomName").val("");//房间号
			$("#bedName").val("");//房间号
			$("#floorNo").val("");//楼层号
			$("#userName").val("");//姓名
			$("#nextEffectDate").val("");//护理评估有效时间
			$("#validDate").val("");//评估有效时间
			$("#staffNo").val("");//护理员
			$("#startDate").val("");//入驻时间
			$("#endDate").val("");//合同截止时间
			$("#userSex").val("");//性别
			$("#nursingCostNo").val("");//护理等级
			$("#assessmentCostNo").val("");//认知
			$("#cognitionStatus").val("");//年龄范围
			$("#age").val("");//年龄范围
			$("#sort").val("");//排序
			$("#staffName").val("");//护理人员
			$("#staffNo").val("");//护理人员
		}

		//查询
		function query(){
			//左侧菜单栏
			layui.use(['table'], function() {
				var table = layui.table;

				//第一个实例
				table.render({
					elem: '#test'//,url: '/demo/table/user/'
					,url:"../elderlyInfo/getElderlyInfoPageList"
					,where: getFormDataOfQuery()
					,request: {
						pageName: 'currentPage' //页码的参数名称，默认：page
						,limitName: 'pageSize' //每页数据量的参数名，默认：limit
					}
					//,count: 10  //数据总数，从服务端得到
					//,data: listData
					,page: true //开启分页
					,limit:10 //每页显示的条数
					//,limits:[3,4,5]
					,groups: 9 //连续页码个数
					,parseData:function(res){
						if(!isNull(res)){
							return{
								"code":res.code,
								"data":res.data.data,
								"count":res.data.totalCount,
								"limit":res.data.pageSize,
							};
						}

					}
					,cols: [
						[  {
							field: 'buildingName',
							title: '楼苑',
						}, {
							field: 'roomName',
							title: '房间号',
						}, {
							field: 'bedName',
							title: '床号',
						}, {
							field: 'userName',
							title: '姓名',
						}, {
							field: 'userSex',
							title: '性别',
						}, {
							field: 'age',
							title: '年龄',
						},{
							field: 'nursingCostName',
							title: '护理等级',
						},  {
							field: 'city6',
							title: '上次查房时间',
							width: 240,
							templet: function(res){
								if(parseInt(res.not_inspect_count) >= 7) {
									return "<div class='table-add-btn'><em>"+getNotNull(res.inspect_date)+"</em><span class='border-bgred'>7天以上未查房</span></div>"
								}else{
									return "<div class='table-add-btn'><em>"+getNotNull(res.inspect_date)+"</em></div>"
								}
							}
						},{
							field: 'operation',
							title: '操作',
							style: 'color:#1C9399;',
							fixed: 'right',
							templet: function(res){
								return '<div class="table-list-btn"><span class="cursor" onclick="addWardRoundRecord(\''+res.userNo+'\')">添加查房记录</span></div>';
							}
						}
						]
					]
					,done:function(res, curr, count){
						$("#totalNum").text(count);
					}
				});
			});
		}

		//获取楼层
		function getFloorData() {
			let buildingNo = $("input#buildingNo").val();
			if(buildingNo && $.trim(buildingNo)){
				$.ajax({
					url:"../baseData/floor/obtainFloorData",
					type:"post",
					dataType:"json",
					data:{"buildingNo":buildingNo},
					success:function (result) {
						if(result.code == "0000") {
							let html = "<option value=''>请选择</option>";
							if (result.data && result.data.length > 0) {
								result.data.forEach(function (v, i) {
									html += "<option value='" + v.floorNo + "'>" + v.floorName + "</option>";
								})
							}
							$("select#floorNo").html(html);

							$("select#floorNo").unbind().on("change", function (e) {
								query();
							})
						}else{
							layer.msg(result.msg);
							$("select#floorNo").html("<option value=''>请选择</option>");
						}
					}
				})
			}else{
				$("select#floorNo").html("<option value=''>请选择</option>");
			}
		}

		//获取查询时候的参数
		function getFormDataOfQuery(){
			var roomName = $("#roomName").val();//房间号
			var bedName = $("#bedName").val();//房间号
			var floorNo = $("#floorNo").val();//楼层号
			var userName = $("#userName").val();//姓名
			var nextEffectDate = $("#nextEffectDate").val();//护理评估有效时间
			var validDate = $("#validDate").val();//评估有效时间
			var staffNo = $("#staffNo").val();//护理员
			var startDate = $("#startDate").val();//入驻时间
			var endDate = $("#endDate").val();//合同截止时间
			var userSex = $("#userSex").val();//性别
			var nursingCostNo = $("#nursingCostNo").val();//护理等级
			var assessmentCostNo = $("#assessmentCostNo").val();//认知
			var cognitionStatus = $("#cognitionStatus").val();//年龄范围
			var age = $("#age").val();//年龄范围
			var sort = $("#sort").val();//排序
			var isStayBack = "1";
			var buildingNo =  $("#buildingNo").val();

			var formDate =
					{
						roomName : roomName,
						bedName : bedName,
						userName : userName,
						floorNo : floorNo,
						nextEffectDate : nextEffectDate,
						validDate : validDate,
						staffNo : staffNo,
						startDate : startDate,
						endDate : endDate,
						userSex : userSex,
						nursingCostNo : nursingCostNo,
						assessmentCostNo : assessmentCostNo,
						cognitionStatus : cognitionStatus,
						age : age,
						sort : sort,
						isStayBack : isStayBack,
						buildingNo : buildingNo
					};
			return formDate;
		}

		//添加查房信息
		function addWardRoundRecord(userNo){
			window.location.href="../wardRound/wardRound_one?userNo="+userNo
			//window.location.href="../wardRound/wardRound_five?userNo="+userNo+"&batchNo=5b60bf480cf34b92aee5138f73bc572e"
		}

		//护理员弹框
		function staffInfoLayerOpen(){
			layui.use(['element' , 'form' , 'table' , 'laydate' , 'layer'], function() {
				var layer = layui.layer;
				layer.open({
					type: 1,
					title: false, //不显示标题栏
					closeBtn: false,
					area: ['800px', '600px'],
					shade: 0.6,
					id: 'payCons', //设定一个id，防止重复弹出
					/*,btn: ['确认支付']*/
					btnAlign: 'c',
					moveType: 1, //拖拽模式，0或者1
					shadeClose: true, //设置允许点遮罩关闭
					content: $("div#nursingStaffInfo"),
					success: function() {
						getStaffInfoList();
						//关闭弹层
						$(".pop-close").click(function() {
							layer.closeAll();
						});
					},

				});
			})
		}

		//获取护理员信息
		function getStaffInfoList(){


			var searchStaffName = $("#searchStaffName").val();
			var formDate =
					{
						staffName : searchStaffName
					};

			//左侧菜单栏
			layui.use(['table'], function() {
				var table = layui.table;
				//第一个实例
				table.render({
					elem: '#test2'//,url: '/demo/table/user/'
					,url:"../elderlyInfo/getYlStaffInfoList"
					,where: formDate
					,request: {
						pageName: 'currentPage' //页码的参数名称，默认：page
						,limitName: 'pageSize' //每页数据量的参数名，默认：limit
					}
					//,count: 10  //数据总数，从服务端得到
					//,data: listData
					,page: true //开启分页
					,limit:10 //每页显示的条数
					//,limits:[3,4,5]
					,groups: 3 //连续页码个数
					,parseData:function(res){
						return{
							"code":res.code,
							"data":res.data.data,
							"count":res.data.totalCount,
							"limit":res.data.pageSize,
						};
					}
					,cols: [
						[
							{
								type: 'radio',
							},
							{
								field: 'staffName',
								title: '姓名',
							}, {
							field: 'post',
							title: '岗位',
						}
						]
					]
					,done:function(res, curr, count){
						$("#totalNum2").text(count);

						//监听事件
						table.on('radio(test2)', function(obj){
							//选中行的数据
							staffNo = obj.data.staffNo;
							staffName = obj.data.staffName;
						});
					}
				});
			});

		}

		function cancelOfLayerOpen(){
			$("#searchStaffName").val("");
			layer.closeAll();
		}

		//弹层的 提交 按钮
		function confirmOfLayerOpen(){
			//给input框赋值
			$("#staffName").val(staffName);
			$("#staffNo").val(staffNo);
			$("#searchStaffName").val("");
			layer.closeAll();
		}

		function isNull(value) {
			return value == null || value === "" || value === undefined;
		}

		function getNotNull(value) {
			if(value && $.trim(value) && value != "null"){
				return value;
			}else{
				return "";
			}
		}

	</script>
	</body>

</html>
